package org.hk.kg.security;

import org.hk.kg.utils.StringUtils;

public class Logon {
	public static final int USER_NOT_EXITS = -1,
		PASSWORD_ERROR = -2,
		LOCAL_CODE_ERROR = -3,
		MOBLIE_CODE_ERROR = -4,
		COMMON_SUCCESS = 1;
	public static final String ERROR_USER_NOT_EXITS = "用户不存在",
		ERROR_PASSWORD_ERROR = "用户密码错误",
		ERROR_LOCAL_CODE_ERROR = "本地交验码错误",
		ERROR_MOBLIE_CODE_ERROR = "手机交验码错误";
	public static final int checkLogin(String usr,String password,String lcl,String mobile)
	{
		if(StringUtils.isEmpty(usr) || !userExits(usr))
		{
			return USER_NOT_EXITS;
		}
		
		if(StringUtils.isEmpty(password) || !checkPassword(usr,password))
		{
			return PASSWORD_ERROR;
		}
		
		if(StringUtils.isEmpty(lcl))
		{
			return MOBLIE_CODE_ERROR;
		}
		
		if(StringUtils.isEmpty(mobile))
		{
			return COMMON_SUCCESS;
		}
		
		return checkCode(lcl,mobile);
	}
	
	private static boolean userExits(String usr)
	{
		return true;
	}
	
	private static boolean checkPassword(String usr,String password)
	{
		return true;
	}
	
	private static int checkCode(String lcl,String mobile)
	{
		return COMMON_SUCCESS;
	}
}
